import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [
    createPersistedState({
      key: 'HEIMA_HKZF',
      reducer({ tokenObj, myCity, houseInfo }) {
        return { tokenObj, myCity, houseInfo }
      }
    })
  ],
  state: {
    // 令牌
    tokenObj: {},
    // 当前城市
    myCity: {},
    cityName: null,
    // 房屋信息
    houseInfo: {},
    // 搜索信息
    community: {},
    // 整租合租
    RentType: null
  },
  getters: {},
  mutations: {
    SET_TOKEN(state, tokenObj) {
      state.tokenObj = tokenObj
    },
    SET_CITYID(state, myCity) {
      state.myCity = myCity
      state.cityName = myCity.value
    },
    SET_HOUSE_INFO(state, houseInfo) {
      state.houseInfo = houseInfo
    },
    SET_COMMUNITY(state, community) {
      state.community = community
    },
    SET_RENT_TYPE(state, RentType) {
      state.RentType = RentType
    }
  },
  actions: {},
  modules: {}
})
